package InterfaceStaff;

import java.awt.Color;
import java.awt.Container;
import java.awt.GridLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.*;

public class MenuUtama extends JFrame implements ActionListener {

    private static final int Lebar = 400;
    private static final int Tinggi = 200;
    private static final int x = 0;
    private static final int y = 0;
    private JButton rekap, buat, exit;
    Container contentPane;
    private ImageIcon exiticon = new ImageIcon("Library/exit.jpg");
    private ImageIcon create = new ImageIcon("Library/create.jpg");
    private ImageIcon rekapicon = new ImageIcon("Library/rekap.jpg");

    public MenuUtama() {
        setSize(Lebar, Tinggi);
        setTitle("Menu Admin Presensi");
        setLocation(x, y);
        setResizable(true);

        contentPane = getContentPane();
        contentPane.setLayout(new GridLayout(1, 3));

        buat = new JButton("Buat Presensi");
        buat.setToolTipText("Buat Presensi");
        buat.setIcon(create);
        buat.setBackground(Color.white);
        this.add(buat);
        buat.addActionListener(this);

        rekap = new JButton("Rekap");
        rekap.setToolTipText("Rekap");
        rekap.setIcon(rekapicon);
        rekap.setBackground(Color.white);
        this.add(rekap);
        rekap.addActionListener(this);

        exit = new JButton("Exit");
        exit.setToolTipText("Exit");
        exit.setIcon(exiticon);
        exit.setBackground(Color.white);
        this.add(exit);
        exit.addActionListener(this);

        setDefaultCloseOperation(EXIT_ON_CLOSE);
    }

    public static void main(String[] args) {
        MenuUtama frame = new MenuUtama();
        frame.setVisible(true);
    }

    public void actionPerformed(ActionEvent e) {
        String button;
        button = e.getActionCommand();

        if (button.equals("Buat Presensi")) {
            FormBuatPresensi f = new FormBuatPresensi();
            f.setVisible(true);
            this.setVisible(false);
        } else if (button.equals("Rekap")) {
            Rekap.Rekap r = new Rekap.Rekap();
            r.setVisible(true);
            this.setVisible(false);
        } else if (button.equals("Exit")) {
            this.dispose();
        }

    }
}
